package com.bangbang.shiro;


import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;

public class LoginRealm extends AuthorizingRealm {

//
//    private TbUserService userService;


//      我们编写授权逻辑的代码
    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
        System.out.println("授权方法....");
        return null;
    }

//    我们编写认证逻辑的方法
    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
        System.out.println("认真方法 ... 登录");
        UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;
//        TbUser user = userService.selectName(token.getUsername());
//        if(user == null){
//            return null;
//        }
//        return new SimpleAuthenticationInfo(user,user.getPassword(), ByteSource.Util.bytes(user.getSalt()),user.getUsername());
        return null;
    }
}
